package org.gongliang.jsmile.authc.sys.service;

import java.util.List;
import java.util.Map;

import org.gongliang.jsmile.authc.sys.dao.SysDepartmentDao;
import org.gongliang.jsmile.authc.sys.entity.SysDepartment;
import org.gongliang.jsmile.authc.sys.vo.SysDepartmentVo;
import org.gongliang.jsmile.common.base.CRUDService;
import org.gongliang.jsmile.common.kit.StrKit;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
* 
* @author 龚亮
* @version 1.0
* @date 2018年08月25日 04:57:24
*/
@Service
public class SysDepartmentService extends CRUDService<SysDepartmentDao, SysDepartment> {

	@Transactional(readOnly = true, rollbackFor = Exception.class)
	public List<SysDepartmentVo> findAllByVo(Map<String, Object> reqMap) {
		return baseDao.findAllByVo(reqMap);
	}

	
	/**
	 * desc:批量删除部门
	 * @param ids
	 * @return
	 */
	@Transactional(readOnly = false, rollbackFor = Exception.class)
	public boolean deleteDepts(String[] ids) {
		int i=0;
		if (ids != null && ids.length >0) {
	        for(String id: ids) {
	        	if(StrKit.notBlank(id)) {
		        	i+=baseDao.deleteByPid(Integer.parseInt(id));
	        	}
	        }
		}
		i+=baseDao.deleteByIds(ids);
		return retBool(i);
	}
}
